﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<Student> person = new List<Student>();
        person.Add(new Student(25, "张三"));
        person.Add(new Student(26, "张华"));
        person.Add(new Student(25, "小西"));
        person.Add(new Student(24, "张军"));
        person.Add(new Student(26, "张雨"));
        var result = from p in person
                     orderby p.age ascending
                     group p by p.age;
        foreach(var element in result)
        {
            Label1.Text += element.Key + "岁组的学生有:";
            foreach(Student pa in element)
            {
                Label1.Text += pa.Name.ToString() + ",";
            }
            Label1.Text += "<br>";
        }
    }
}